<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!--{include file='comm/header.tpl'}-->
    <title>导航设置</title>
    <!--{include file='comm/comm_cal.tpl'}-->
</head>
<body>

<!--{include file='comm/naviBanner.tpl'}-->

<style>
    .opa{
        opacity: 0.5; 
    }
</style>

<div class="container">

    <!--{include file='comm/menu.tpl'}-->
    <div class="comm_content">

            <div class="items clearfix">
                <h2 class="tal" style="">正在操作：导航设置</h2>
                <div class="items2">

                    <form onsubmit="return false;" id="edit_form">
                        <table>
                            <tbody>
                            <tr>
                                <td style="width:100px;" class="tar">导航菜单：</td>
                                <td>
                                    <input id="navName0" name="navName0" onclick = "nav.clearOpa(this)" onblur="nav.doOpa(this)"  <!--{if $navData[0]}-->value="<!--{$navData[0].navName}-->"<!--{else}-->value="导航菜单名称" class="opa" <!--{/if}-->  type="text"   style="width:140px;" id="percent_1">
                                    <input id="navLink0" name="navLink0" onclick = "nav.clearOpaLink(this)" onblur="nav.doOpaLink(this)" <!--{if $navData[0]}-->value="<!--{$navData[0].navLink}-->"<!--{else}-->value="导航菜单链接" class="opa" <!--{/if}-->  type="text"   style="width:580px;" id="percent_1">
                                    <input id="navSort0" name="navSort0" onclick = "nav.clearOpaSort(this)" onblur="nav.doOpaSort(this)" <!--{if $navData[0]}-->value="<!--{$navData[0].navSort}-->"<!--{else}-->value="排序号" class="opa" <!--{/if}-->  type="text"   style="width:80px;" id="percent_1">
                                </td>
                            </tr>
                            <tr>
                                <td style="width:100px;" class="tar">导航菜单：</td>
                                <td>
                                    <input id="navName1" name="navName1" onclick = "nav.clearOpa(this)" onblur="nav.doOpa(this)" onclick = "nav.clearOpa(this)" onblur="nav.doOpa(this)" <!--{if $navData[1]}-->value="<!--{$navData[1].navName}-->"<!--{else}-->value="导航菜单名称" class="opa" <!--{/if}-->  type="text"   style="width:140px;" id="percent_1">
                                    <input id="navLink1" name="navLink1" onclick = "nav.clearOpaLink(this)" onblur="nav.doOpaLink(this)" <!--{if $navData[1]}-->value="<!--{$navData[1].navLink}-->"<!--{else}-->value="导航菜单链接" class="opa" <!--{/if}--> type="text"   style="width:580px;" id="percent_1">
                                    <input id="navSort1" name="navSort1" onclick = "nav.clearOpaSort(this)" onblur="nav.doOpaSort(this)"  <!--{if $navData[1]}-->value="<!--{$navData[1].navSort}-->"<!--{else}-->value="排序号" class="opa" <!--{/if}--> type="text"   style="width:80px;" id="percent_1">
                                </td>
                            </tr>
                            <tr>
                                <td style="width:100px;" class="tar">导航菜单：</td>
                                <td>
                                    <input id="navName2" name="navName2" onclick = "nav.clearOpa(this)" onblur="nav.doOpa(this)"  <!--{if $navData[2]}-->value="<!--{$navData[2].navName}-->"<!--{else}-->value="导航菜单名称" class="opa"<!--{/if}-->  type="text"   style="width:140px;" id="percent_1">
                                    <input id="navLink2" name="navLink2" onclick = "nav.clearOpaLink(this)" onblur="nav.doOpaLink(this)"  <!--{if $navData[2]}-->value="<!--{$navData[2].navLink}-->"<!--{else}-->value="导航菜单链接" class="opa"<!--{/if}--> type="text"   style="width:580px;" id="percent_1">
                                    <input id="navSort2" name="navSort2" onclick = "nav.clearOpaSort(this)" onblur="nav.doOpaSort(this)"  <!--{if $navData[2]}-->value="<!--{$navData[2].navSort}-->"<!--{else}-->value="排序号" class="opa"<!--{/if}--> type="text"   style="width:80px;" id="percent_1">
                                </td>
                            </tr>
                            <tr>
                                <td style="width:100px;" class="tar">导航菜单：</td>
                                <td>
                                    <input id="navName3" name="navName3" onclick = "nav.clearOpa(this)" onblur="nav.doOpa(this)"  <!--{if $navData[3]}-->value="<!--{$navData[3].navName}-->"<!--{else}-->value="导航菜单名称" class="opa"<!--{/if}-->  type="text"   style="width:140px;" id="percent_1">
                                    <input id="navLink3" name="navLink3" onclick = "nav.clearOpaLink(this)" onblur="nav.doOpaLink(this)"  <!--{if $navData[3]}-->value="<!--{$navData[3].navLink}-->"<!--{else}-->value="导航菜单链接" class="opa"<!--{/if}--> type="text"   style="width:580px;" id="percent_1">
                                    <input id="navSort3" name="navSort3" onclick = "nav.clearOpaSort(this)" onblur="nav.doOpaSort(this)"  <!--{if $navData[3]}-->value="<!--{$navData[3].navSort}-->"<!--{else}-->value="排序号" class="opa"<!--{/if}--> type="text"   style="width:80px;" id="percent_1">
                                </td>
                            </tr>
                            <tr>
                                <td style="width:100px;" class="tar">导航菜单：</td>
                                <td>
                                    <input id="navName4" name="navName4" onclick = "nav.clearOpa(this)" onblur="nav.doOpa(this)"  <!--{if $navData[4]}-->value="<!--{$navData[4].navName}-->"<!--{else}-->value="导航菜单名称" class="opa"<!--{/if}-->  type="text"   style="width:140px;" id="percent_1">
                                    <input id="navLink4" name="navLink4" onclick = "nav.clearOpaLink(this)" onblur="nav.doOpaLink(this)"  <!--{if $navData[4]}-->value="<!--{$navData[4].navLink}-->"<!--{else}-->value="导航菜单链接" class="opa"<!--{/if}--> type="text"   style="width:580px;" id="percent_1">
                                    <input id="navSort4" name="navSort4" onclick = "nav.clearOpaSort(this)" onblur="nav.doOpaSort(this)" <!--{if $navData[4]}-->value="<!--{$navData[4].navSort}-->"<!--{else}-->value="排序号" class="opa"<!--{/if}--> type="text"   style="width:80px;" id="percent_1">
                                </td>
                            </tr>
                            <tr>
                                <td style="width:100px;" class="tar">导航菜单：</td>
                                <td>
                                    <input id="navName5" name="navName5" onclick = "nav.clearOpa(this)" onblur="nav.doOpa(this)" class="opa" <!--{if $navData[5]}-->value="<!--{$navData[5].navName}-->"<!--{else}-->value="导航菜单名称" class="opa"<!--{/if}-->  type="text"   style="width:140px;" id="percent_1">
                                    <input id="navLink5" name="navLink5" onclick = "nav.clearOpaLink(this)" onblur="nav.doOpaLink(this)" class="opa" <!--{if $navData[5]}-->value="<!--{$navData[5].navLink}-->"<!--{else}-->value="导航菜单链接" class="opa"<!--{/if}--> type="text"   style="width:580px;" id="percent_1">
                                    <input id="navSort5" name="navSort5" onclick = "nav.clearOpaSort(this)" onblur="nav.doOpaSort(this)" class="opa" <!--{if $navData[5]}-->value="<!--{$navData[5].navSort}-->"<!--{else}-->value="排序号" class="opa"<!--{/if}--> type="text"   style="width:80px;" id="percent_1">
                                </td>
                            </tr>

                            </tbody>
                        </table>
                    </form>

                </div>
            </div>

            <div style="width:100%;margin-top: 20px;text-align: center;">
                <input type="button" value="保存" onclick="nav.save();" class="btn">
            </div>

        </div>

</div>

<script>
    var nav = {
        clearOpa:function(ythis){
            if($(ythis).val() == '导航菜单名称'){
                $(ythis).removeClass('opa');
                $(ythis).val('');
            }
        },

        doOpa:function(ythis){
            if($(ythis).val() == ''){
                $(ythis).addClass('opa');
                $(ythis).val('导航菜单名称');
            }
        },
        clearOpaLink:function(ythis){
            if($(ythis).val() == '导航菜单链接'){
                $(ythis).removeClass('opa');
                $(ythis).val('');
            }
        },

        doOpaLink:function(ythis){
            if($(ythis).val() == ''){
                $(ythis).addClass('opa');
                $(ythis).val('导航菜单链接');
            }
        },
        clearOpaSort:function(ythis){
            if($(ythis).val() == '排序号'){
                $(ythis).removeClass('opa');
                $(ythis).val('');
            }
        },

        doOpaSort:function(ythis){
            if($(ythis).val() == ''){
                $(ythis).addClass('opa');
                $(ythis).val('排序号');
            }
        },

        save: function(){
            var navName = '';
            var navName1 = '';
            var errorLink_arr = new Array();
            var errorSort_arr = new Array();
            var dateStr = '';
            var dateArr = new Array();
            var data_json = '';
            for (i = 0; i <= 5; i++)
            {
                if($('#navName'+ i + '').val() != ''&&$('#navName'+ i +'').val() != '导航菜单名称'){
                    navName1 += $('#navName'+ i +'').val();

                    if(E.len($('#navName'+ i +'').val())>8){

                        E.alert($('#navName'+ i + '').val()+'菜单长度不能大于4');
                        return ;

                    }

                    if($('#navLink'+ i + '').val() == '' || $('#navLink'+ i + '').val() == '导航菜单链接'){
                        E.alert('请输入'+$('#navName'+ i + '').val()+'菜单的链接');
                        return;
                    }
                    if($('#navSort'+ i + '').val() == '' || $('#navSort'+ i + '').val() == '排序号'){
                        E.alert('请输入'+$('#navName'+ i + '').val()+'菜单的排序号');
                        return;
                    }

                    var navName = $('#navName'+ i + '').val();
                    var navLink = $('#navLink'+ i + '').val();
                    var navSort = $('#navSort'+ i + '').val();
                    dateStr = [navName,navLink,navSort];

                    dateArr.push(dateStr);

                }
            }
            if(navName1 == ''){
                E.alert('请至少输入一个导航菜单名称');
                return;
            }

            $.ajax({
                type:"POST",
                url: "/invokingAjax-backend/content/navigation.ajax?operFlg=1",
                dataType: "JSON",
                data: {data:dateArr},
                success: function(result){

                    if(result.code == '200'){

                        E.alert(result.message,2)

                    }else{

                        E.alert(result.message)

                    }
                }
            });

        }
    }
</script>

</body>
</html>